package Market;


import sim.engine.*;
import java.util.*;

public class ISO implements Steppable
   {
	private static final long serialVersionUID = 6628525522939315274L;
	
	Initials.InitNode   initnode;
	Initials.InitBranch initbranch;
	
	ArrayList GenCoList;
	
	double[][] NodeData;
	double[][] BranchData;	
	double[] LoadProfile;
	double[][] LoadProfileD;
	double[][] TSupplyOffer; 
	double[][] RSupplyOffer; 
	double[][] GenCoData;
	double[][] LSEData;
	
	Market market;
	int J;
	int I;
	int K;
	int N;
	int hour;
	
	public ISO(int i,int j, int k, int n, int h, double[][] gencodata, double[][] lsedata, Market mt){
		
		
		
		market = mt;
		I = i;
		J =j;
		K=k;
		N=n;
		hour = h;
		
		GenCoData    = new double[I][8];
		LSEData      = new double[J][26];
		GenCoData = gencodata;
		LSEData=lsedata;
		//LoadProfileD = loadprofile;
		
	}
	
//-----------------------------------------------------------------------------------------------------------------------------------------
    public void step(SimState state)
        {
    	
    	NodeData   = new double[1][2];
    	BranchData = new double[5][4];
    	LoadProfileD = new double[24][3];
    	LoadProfile = new double[3];
    	TSupplyOffer = new double[I][4];
    	RSupplyOffer = new double[I][4];
    	
    	initnode = new Initials.InitNode();
    	initbranch = new Initials.InitBranch();   	
    	NodeData   = initnode.getNodeData();
    	BranchData = initbranch.getBranchData();
    	
    	LoadProfileD = market.getLoadProfile();
    	
    	for (int i=0; i<3; i++){
    	LoadProfile[i] =  LoadProfileD[hour][i];
    	}
    	
    	TSupplyOffer = market.getTSupplyOffer();
    	RSupplyOffer = market.getRSupplyOffer();
    	
    	
    	/*
    	for (int i=0; i<I; i++){
    	GenCoList = market.getGenCo();
    	GenCo gen = (GenCo) GenCoList.get(i);
    	gen.chooseNextAction();    	
    	}
    	*/

    	
    	/*
    	  for (int m=0;m<1;m++){
    		for (int b=0;b<2;b++){
    			System.out.println("NodeData  "+NodeData[m][b]);
    		}
    	}
    	  for (int m=0;m<3;m++){
      		for (int b=0;b<4;b++){
      			System.out.println("BranchData  "+BranchData[m][b]);
      		}
      	}
    	  for (int m=0;m<J;m++){
 
      			System.out.println("LoadProfile  "+LoadProfile[m]);
  
      	}
    	  for (int m=0;m<I;m++){
      		for (int b=0;b<4;b++){
      			System.out.println("TSupplyOffer  "+TSupplyOffer[m][b]);
      		}
      	}
*/   	 
    	  OptimalPowerFlow opf = new OptimalPowerFlow(NodeData, BranchData, LoadProfile, TSupplyOffer, market, GenCoData, LSEData,  hour, I, J, K, N);
        
        }
   
    
   
   }